<%@page import="edu.ncsu.csc.itrust.beans.LabTechProcedureBean"%>

<script type="text/javascript">
	function findlt(){
		var ele = document.getElementById("findLtdiv");
		if(ele.style.display == "block"){
			ele.style.display = "none";
		}else{
			ele.style.display = "block";
		}
	}
	function gateLP(){
		var checked = false;
		var radio = document.getElementsByName("addLtId");
		for(i=0; i < radio.length; i++){
			if(radio[i].checked){ checked = true; }
		}
		if( checked != true ){
			alert("Please check your inputs: Lab Tech");
		}else{
			if(document.getElementById("addLabProcPriority").value == "" ){
				alert("Please check your inputs: Priority");
			}else{
				document.forms[0].submit();
			}
		}
	}  
</script>

<div align="center">
<table class="fTable" align="center">
	<tr>
		<th colspan="8">Laboratory Procedures</th>
	</tr>
	<tr class="subHeader">
		<td>LOINC Code</td>
		<td>Priority</td>
		<td>Status</td>
		<td>Assigned Tech</td>
		<td>Commentary</td>
		<td>Results</td>
		<td style="width: 60px;">Updated Date</td>
		<td>Action</td>
	</tr>
	<%
		if (lpBeans.size() == 0) {
	%>
	<tr>
		<td colspan="8" style="text-align: center;">No Laboratory
		Procedures on record</td>
	</tr>
	<%
		} else {
	%>
	<%
		loggingAction.logEvent(TransactionType.LAB_RESULTS_VIEW,
					loggedInMID.longValue(), ovID, "");
	%>
	<%
		for (LabProcedureBean labproc : lpBeans) {
	%>
	<%
		String ltname = "Unassigned";
	%>
	<%
		if (labproc.getLtID() != 0) {
	%>
	<%
		ltname = prodDAO.getPersonnelDAO().getName(
							labproc.getLtID());
	%>
	<%
		}
	%>
	<tr>
		<td align="center"><a
			href='/iTrust/auth/hcp/UpdateLabProc.jsp?ID=<%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getProcedureID()))%>'><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getLoinc()))%></a></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getPriority()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getStatus()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml("" + (ltname))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getCommentary()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getResults()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (labproc.getTimestamp()))%></td>
		<td>
		<%
			if (labproc.getStatus().equals("IN TRANSIT")
							|| labproc.getStatus().equals("RECEIVED")) {
		%>
		<a href='javascript:removeID('removeLabProcID','<%=StringEscapeUtils.escapeHtml(""
								+ (labproc.getProcedureID()))%>');'>Remove</a>
		<%
			}
		%>
		</td>
	</tr>
	<%
		}
	%>
	<%
		}
	%>
	<tr>
		<th colspan="8" style="text-align: center;">Add New</th>
	</tr>
	<tr>
		<td colspan="8" align="center"><select name="addLabProcID"
			style="font-size: 10px;">
			<option value="">-- Please Select a Procedure --</option>
			<%
				for (LOINCbean loinc : prodDAO.getLOINCDAO().getAllLOINC()) {
			%>
			<option value="<%=loinc.getLabProcedureCode()%>"><%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getLabProcedureCode()))%>
			- <%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getComponent()))%> -
			<%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getKindOfProperty()))%>
			- <%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getTimeAspect()))%> -
			<%=StringEscapeUtils.escapeHtml("" + (loinc.getSystem()))%> - <%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getScaleType()))%>
			- <%=StringEscapeUtils.escapeHtml(""
						+ (loinc.getMethodType()))%></option>
			<%
				}
			%>
		</select> <select id="addLabProcPriority" name="addLabProcPriority"
			style="font-size: 10px;">
			<option value="">-- Please Select a Priority --</option>
			<option value="3">3</option>
			<option value="2">2</option>
			<option value="1">1</option>
		</select> <input type="button" id="findLabTech" onclick="findlt();"
			value="Show/Hide Lab Tech"> <input type="submit" id="addLP"
			name="addLP" onclick="gateLP();" value="Add Lab Procedure"></td>
	</tr>
</table>
<div id="findLtdiv" style="display: none">
<table class="fTable" align="center">
	<tr>
		<th colspan="7" style="width: 838px">Lab Tech List</th>
	</tr>
	<tr class="subHeader">
		<td></td>
		<td>Name</td>
		<td>Specialty</td>
		<td>Pending</td>
		<td>Priority 1</td>
		<td>Priority 2</td>
		<td>Priority 3</td>
	</tr>
	<%
		List<LabTechProcedureBean> techbeans = action.getAllLabTechs();
	%>
	<%
		if (techbeans.size() == 0) {
	%>
	<tr>
		<td align="center" colspan="7">No Lab Techs on Record</td>
	</tr>
	<%
		} else {
	%>
	<%
		for (LabTechProcedureBean ltbean : techbeans) {
	%>
	<tr>
		<td><input type="radio" id="addLtId" name="addLtId"
			value="<%=ltbean.getLtId()%>"></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getName()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getSpecialty()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getTotalProcedures()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getTotalP1()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getTotalP2()))%></td>
		<td align="center"><%=StringEscapeUtils.escapeHtml(""
							+ (ltbean.getTotalP3()))%></td>
	</tr>
	<%
		}
	%>
	<%
		}
	%>
</table>
</div>
</div>